* whether to fetch the primary object after fetching its
* detached metadata (no need if it's already stored). */
gboolean object_is_stored;
+
+ OstreeCollectionRef *requested_ref; /* (nullable) */
} FetchObjectData;
typedef struct {
char *path;
OstreeObjectType objtype;
guint recursion_depth; /* NB: not used anymore, though might be nice to print */
+ OstreeCollectionRef *requested_ref; /* (nullable) */
} ScanObjectQueueData;
static void start_fetch (OtPullData *pull_data, FetchObjectData *fetch);
static void start_fetch_deltapart (OtPullData *pull_data,
FetchStaticDeltaData *fetch);
static gboolean fetcher_queue_is_full (OtPullData *pull_data);
-static void queue_scan_one_metadata_object (OtPullData *pull_data,
- const char *csum,
- OstreeObjectType objtype,
- const char *path,
- guint recursion_depth);
-
-static void queue_scan_one_metadata_object_c (OtPullData *pull_data,
- const guchar *csum,
- OstreeObjectType objtype,
- const char *path,
- guint recursion_depth);
-
-static gboolean scan_one_metadata_object_c (OtPullData *pull_data,
- const guchar *csum,
- OstreeObjectType objtype,
- const char *path,
- guint recursion_depth,
- GCancellable *cancellable,
- GError **error);
+static void queue_scan_one_metadata_object (OtPullData *pull_data,
+ const char *csum,
+ OstreeObjectType objtype,
+ const char *path,
+ guint recursion_depth,
+ const OstreeCollectionRef *ref);
+
+static void queue_scan_one_metadata_object_c (OtPullData *pull_data,
+ const guchar *csum,
+ OstreeObjectType objtype,
+ const char *path,
+ guint recursion_depth,
+ const OstreeCollectionRef *ref);
+
+static gboolean scan_one_metadata_object_c (OtPullData *pull_data,
+ const guchar *csum,
+ OstreeObjectType objtype,
+ const char *path,
+ guint recursion_depth,
+ const OstreeCollectionRef *ref,
+ GCancellable *cancellable,
+ GError **error);
static gboolean
update_progress (gpointer user_data)
scan_data->objtype,
scan_data->path,
scan_data->recursion_depth,
+ scan_data->requested_ref,
pull_data->cancellable,
&error);
check_outstanding_requests_handle_error (pull_data, &error);
g_free (scan_data->path);
+ if (scan_data->requested_ref != NULL)
+ ostree_collection_ref_free (scan_data->requested_ref);
g_free (scan_data);
return G_SOURCE_CONTINUE;
}
}
static void
-enqueue_one_object_request (OtPullData *pull_data,
- const char *checksum,
- OstreeObjectType objtype,
- const char *path,
- gboolean is_detached_meta,
- gboolean object_is_stored);
+enqueue_one_object_request (OtPullData *pull_data,
+ const char *checksum,
+ OstreeObjectType objtype,
+ const char *path,
+ gboolean is_detached_meta,
+ gboolean object_is_stored,
+ const OstreeCollectionRef *ref);
static gboolean
matches_pull_dir (const char *current_file,
/* Not available locally, queue a HTTP request */
g_hash_table_add (pull_data->requested_content, file_checksum);
- enqueue_one_object_request (pull_data, file_checksum, OSTREE_OBJECT_TYPE_FILE, path, FALSE, FALSE);
+ enqueue_one_object_request (pull_data, file_checksum, OSTREE_OBJECT_TYPE_FILE, path, FALSE, FALSE, NULL);
file_checksum = NULL; /* Transfer ownership */
}
g_autofree char *subpath = g_strconcat (path, dirname, "/", NULL);
queue_scan_one_metadata_object_c (pull_data, tree_csum_bytes,
- OSTREE_OBJECT_TYPE_DIR_TREE, subpath, recursion_depth + 1);
+ OSTREE_OBJECT_TYPE_DIR_TREE, subpath, recursion_depth + 1, NULL);
queue_scan_one_metadata_object_c (pull_data, meta_csum_bytes,
- OSTREE_OBJECT_TYPE_DIR_META, subpath, recursion_depth + 1);
+ OSTREE_OBJECT_TYPE_DIR_META, subpath, recursion_depth + 1, NULL);
}
return TRUE;
{
g_variant_unref (fetch_data->object);
g_free (fetch_data->path);
+ if (fetch_data->requested_ref)
+ ostree_collection_ref_free (fetch_data->requested_ref);
g_free (fetch_data);
}
goto out;
}
- queue_scan_one_metadata_object_c (pull_data, csum, objtype, fetch_data->path, 0);
+ queue_scan_one_metadata_object_c (pull_data, csum, objtype, fetch_data->path, 0, fetch_data->requested_ref);
out:
pull_data->n_outstanding_metadata_write_requests--;
g_hash_table_add (pull_data->fetched_detached_metadata, g_strdup (checksum));
if (!fetch_data->object_is_stored)
- enqueue_one_object_request (pull_data, checksum, objtype, fetch_data->path, FALSE, FALSE);
+ enqueue_one_object_request (pull_data, checksum, objtype, fetch_data->path, FALSE, FALSE, fetch_data->requested_ref);
else
- queue_scan_one_metadata_object (pull_data, checksum, objtype, fetch_data->path, 0);
+ queue_scan_one_metadata_object (pull_data, checksum, objtype, fetch_data->path, 0, fetch_data->requested_ref);
}
/* When traversing parents, do not fail on a missing commit.
if (pull_data->has_tombstone_commits)
{
enqueue_one_object_request (pull_data, checksum, OSTREE_OBJECT_TYPE_TOMBSTONE_COMMIT,
- fetch_data->path, FALSE, FALSE);
+ fetch_data->path, FALSE, FALSE, NULL);
}
}
}
g_hash_table_add (pull_data->fetched_detached_metadata, g_strdup (checksum));
if (!fetch_data->object_is_stored)
- enqueue_one_object_request (pull_data, checksum, objtype, fetch_data->path, FALSE, FALSE);
+ enqueue_one_object_request (pull_data, checksum, objtype, fetch_data->path, FALSE, FALSE, fetch_data->requested_ref);
else
- queue_scan_one_metadata_object (pull_data, checksum, objtype, fetch_data->path, 0);
+ queue_scan_one_metadata_object (pull_data, checksum, objtype, fetch_data->path, 0, fetch_data->requested_ref);
}
else
{
}
static gboolean
-scan_commit_object (OtPullData *pull_data,
- const char *checksum,
- guint recursion_depth,
- GCancellable *cancellable,
- GError **error)
+scan_commit_object (OtPullData *pull_data,
+ const char *checksum,
+ guint recursion_depth,
+ const OstreeCollectionRef *ref,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
/* If we found a legacy transaction flag, assume we have to scan.
{
queue_scan_one_metadata_object_c (pull_data, parent_csum_bytes,
OSTREE_OBJECT_TYPE_COMMIT, NULL,
- recursion_depth + 1);
+ recursion_depth + 1, NULL);
}
else if (parent_csum_bytes != NULL && depth > 0)
{
queue_scan_one_metadata_object_c (pull_data, parent_csum_bytes,
OSTREE_OBJECT_TYPE_COMMIT,
NULL,
- recursion_depth + 1);
+ recursion_depth + 1,
+ NULL);
}
}
goto out;
queue_scan_one_metadata_object_c (pull_data, tree_contents_csum_bytes,
- OSTREE_OBJECT_TYPE_DIR_TREE, "/", recursion_depth + 1);
+ OSTREE_OBJECT_TYPE_DIR_TREE, "/", recursion_depth + 1, NULL);
queue_scan_one_metadata_object_c (pull_data, tree_meta_csum_bytes,
- OSTREE_OBJECT_TYPE_DIR_META, NULL, recursion_depth + 1);
+ OSTREE_OBJECT_TYPE_DIR_META, NULL, recursion_depth + 1, NULL);
}
ret = TRUE;
}
static void
-queue_scan_one_metadata_object (OtPullData *pull_data,
- const char *csum,
- OstreeObjectType objtype,
- const char *path,
- guint recursion_depth)
+queue_scan_one_metadata_object (OtPullData *pull_data,
+ const char *csum,
+ OstreeObjectType objtype,
+ const char *path,
+ guint recursion_depth,
+ const OstreeCollectionRef *ref)
{
guchar buf[OSTREE_SHA256_DIGEST_LEN];
ostree_checksum_inplace_to_bytes (csum, buf);
- queue_scan_one_metadata_object_c (pull_data, buf, objtype, path, recursion_depth);
+ queue_scan_one_metadata_object_c (pull_data, buf, objtype, path, recursion_depth, ref);
}
static void
-queue_scan_one_metadata_object_c (OtPullData *pull_data,
- const guchar *csum,
- OstreeObjectType objtype,
- const char *path,
- guint recursion_depth)
+queue_scan_one_metadata_object_c (OtPullData *pull_data,
+ const guchar *csum,
+ OstreeObjectType objtype,
+ const char *path,
+ guint recursion_depth,
+ const OstreeCollectionRef *ref)
{
ScanObjectQueueData *scan_data = g_new0 (ScanObjectQueueData, 1);
scan_data->objtype = objtype;
scan_data->path = g_strdup (path);
scan_data->recursion_depth = recursion_depth;
+ scan_data->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL;
g_queue_push_tail (&pull_data->scan_object_queue, scan_data);
ensure_idle_queued (pull_data);
}
static gboolean
-scan_one_metadata_object_c (OtPullData *pull_data,
- const guchar *csum,
- OstreeObjectType objtype,
- const char *path,
- guint recursion_depth,
- GCancellable *cancellable,
- GError **error)
+scan_one_metadata_object_c (OtPullData *pull_data,
+ const guchar *csum,
+ OstreeObjectType objtype,
+ const char *path,
+ guint recursion_depth,
+ const OstreeCollectionRef *ref,
+ GCancellable *cancellable,
+ GError **error)
{
g_autofree char *tmp_checksum = ostree_checksum_from_bytes (csum);
g_autoptr(GVariant) object = ostree_object_name_serialize (tmp_checksum, objtype);
g_hash_table_add (pull_data->requested_metadata, g_variant_ref (object));
do_fetch_detached = (objtype == OSTREE_OBJECT_TYPE_COMMIT);
- enqueue_one_object_request (pull_data, tmp_checksum, objtype, path, do_fetch_detached, FALSE);
+ enqueue_one_object_request (pull_data, tmp_checksum, objtype, path, do_fetch_detached, FALSE, ref);
}
else if (is_stored && objtype == OSTREE_OBJECT_TYPE_COMMIT)
{
* detached metadata before scanning it, in case new signatures appear.
* https://github.com/projectatomic/rpm-ostree/issues/630 */
if (!g_hash_table_contains (pull_data->fetched_detached_metadata, tmp_checksum))
- enqueue_one_object_request (pull_data, tmp_checksum, objtype, path, TRUE, TRUE);
+ enqueue_one_object_request (pull_data, tmp_checksum, objtype, path, TRUE, TRUE, ref);
else
{
- if (!scan_commit_object (pull_data, tmp_checksum, recursion_depth,
+ if (!scan_commit_object (pull_data, tmp_checksum, recursion_depth, ref,
pull_data->cancellable, error))
return FALSE;
}
static void
-enqueue_one_object_request (OtPullData *pull_data,
- const char *checksum,
- OstreeObjectType objtype,
- const char *path,
- gboolean is_detached_meta,
- gboolean object_is_stored)
+enqueue_one_object_request (OtPullData *pull_data,
+ const char *checksum,
+ OstreeObjectType objtype,
+ const char *path,
+ gboolean is_detached_meta,
+ gboolean object_is_stored,
+ const OstreeCollectionRef *ref)
{
gboolean is_meta;
FetchObjectData *fetch_data;
fetch_data->path = g_strdup (path);
fetch_data->is_detached_meta = is_detached_meta;
fetch_data->object_is_stored = object_is_stored;
+ fetch_data->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL;
if (is_meta)
pull_data->n_requested_metadata++;
* for it as logically part of the delta fetch.
*/
g_hash_table_add (pull_data->requested_fallback_content, g_strdup (checksum));
- enqueue_one_object_request (pull_data, checksum, OSTREE_OBJECT_TYPE_FILE, NULL, FALSE, FALSE);
+ enqueue_one_object_request (pull_data, checksum, OSTREE_OBJECT_TYPE_FILE, NULL, FALSE, FALSE, NULL);
checksum = NULL; /* We transferred ownership to the requested_content hash */
}
}
}
static gboolean
-process_one_static_delta (OtPullData *pull_data,
- const char *from_revision,
- const char *to_revision,
- GVariant *delta_superblock,
- GCancellable *cancellable,
- GError **error)
+process_one_static_delta (OtPullData *pull_data,
+ const char *from_revision,
+ const char *to_revision,
+ GVariant *delta_superblock,
+ const OstreeCollectionRef *ref,
+ GCancellable *cancellable,
+ GError **error)
{
gboolean ret = FALSE;
gboolean delta_byteswap;
fetch_data->object = ostree_object_name_serialize (to_checksum, OSTREE_OBJECT_TYPE_COMMIT);
fetch_data->is_detached_meta = FALSE;
fetch_data->object_is_stored = FALSE;
+ fetch_data->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL;
ostree_repo_write_metadata_async (pull_data->repo, OSTREE_OBJECT_TYPE_COMMIT, to_checksum,
to_commit,
OtPullData *pull_data;
char *from_revision;
char *to_revision;
+ OstreeCollectionRef *requested_ref; /* (nullable) */
} FetchDeltaSuperData;
static void
goto out;
}
- queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0);
+ queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0, fdata->requested_ref);
}
else
{
delta_superblock_data, FALSE));
g_ptr_array_add (pull_data->static_delta_superblocks, g_variant_ref (delta_superblock));
- if (!process_one_static_delta (pull_data, from_revision, to_revision, delta_superblock,
+ if (!process_one_static_delta (pull_data, from_revision, to_revision, delta_superblock, fdata->requested_ref,
pull_data->cancellable, error))
goto out;
}
out:
g_free (fdata->from_revision);
g_free (fdata->to_revision);
+ if (fdata->requested_ref)
+ ostree_collection_ref_free (fdata->requested_ref);
g_free (fdata);
g_assert (pull_data->n_outstanding_metadata_fetches > 0);
pull_data->n_outstanding_metadata_fetches--;
static void
initiate_delta_request (OtPullData *pull_data,
const char *from_revision,
- const char *to_revision)
+ const char *to_revision,
+ const OstreeCollectionRef *ref)
{
g_autofree char *delta_name =
_ostree_get_relative_static_delta_superblock_path (from_revision, to_revision);
fdata->pull_data = pull_data;
fdata->from_revision = g_strdup (from_revision);
fdata->to_revision = g_strdup (to_revision);
+ fdata->requested_ref = (ref != NULL) ? ostree_collection_ref_dup (ref) : NULL;
_ostree_fetcher_request_to_membuf (pull_data->fetcher,
pull_data->content_mirrorlist,
/* Are deltas disabled? OK, just start an object fetch and be done */
if (pull_data->disable_static_deltas)
{
- queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0);
+ queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0, ref);
return TRUE;
}
return FALSE;
if (delta_from_revision) /* Did we find a delta FROM commit? */
- initiate_delta_request (pull_data, delta_from_revision, to_revision);
+ initiate_delta_request (pull_data, delta_from_revision, to_revision, ref);
else if (have_scratch_delta) /* No delta FROM, do we have a scratch? */
- initiate_delta_request (pull_data, NULL, to_revision);
+ initiate_delta_request (pull_data, NULL, to_revision, ref);
else if (pull_data->require_static_deltas) /* No deltas found; are they required? */
{
set_required_deltas_error (error, (ref != NULL) ? ref->ref_name : "", to_revision);
return FALSE;
}
else /* No deltas, fall back to object fetches. */
- queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0);
+ queue_scan_one_metadata_object (pull_data, to_revision, OSTREE_OBJECT_TYPE_COMMIT, NULL, 0, ref);
}
else if (ref != NULL)
{
/* This is similar to the below, except we *might* use the previous
* commit, or we might do a scratch delta first.
*/
- initiate_delta_request (pull_data, delta_from_revision ?: NULL, to_revision);
+ initiate_delta_request (pull_data, delta_from_revision ?: NULL, to_revision, ref);
}
else
{
/* Legacy path without a summary file - let's try a scratch delta, if that
* doesn't work, it'll drop down to object requests.
*/
- initiate_delta_request (pull_data, NULL, to_revision);
+ initiate_delta_request (pull_data, NULL, to_revision, NULL);
}
return TRUE;